package com.LeeCode;

/**
 * 对角线最长的矩形的面积
 */

public class Code3000 {
    public static void main(String[] args) {
        int[][] mat = {{9, 3}, {8, 6}, {2, 10}};
        System.out.println(new Code3000().areaOfMaxDiagonal(mat));
    }

    public int areaOfMaxDiagonal(int[][] dimensions) {
        int len = Integer.MIN_VALUE, area = Integer.MIN_VALUE;

        for (int[] d : dimensions) {
            int curLen = d[0] * d[0] + d[1] * d[1];
            if (curLen > len) {
                area = d[0] * d[1];
                len = curLen;
            } else if (curLen == len) {
                area = Math.max(area, d[0] * d[1]);
            }
        }

        return area;
    }
}
